Document vs SQL Database

Here is my amateur opinion on choosing between a document database like CouchDB or MongoDB vs a sequel database like PostgreSQL or MariaDB

Which one should I choose?

Is your data simple and the schema needs to be flexible? Choose a Document DB

Does your data have multiple relationships that link it together? Choose a SQL DB

SQL

DOCUMENT:

I'd say use document db if

Use an SQL if

I'm lost

If you've gotten this far and still don't know what I'm talking about, then just choose a Document DB. A lot of my beginner projects was built with CouchDB. It's easy to understand and fast to set up and update.

Like most people, I created a note taking app. This was perfect for a Document DB.

flowchart TB

%% Hardware
noteIds("notesId []")
userId("userId")


subgraph Your DB

	subgraph "User 👨‍🦲"
		id
		name
		email
		password
		noteIds
	end
	
	subgraph "Note 📝"
		id
		title
		list
		userId <--> noteIds
	end
	
end

You can see I 'link' the data points of User and Note with a noteIds and userId.

I use 'link' in quotes because when I query the User data, I'm only receiving an array of note ids, then I have to make another query to the notes and find the related ids. As your db grows sooner or later you'll hit this wall of creating these manual links between data.

developer_box📦